/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : i_eeprom.h
  * @brief          : Header for i_eeprom.c file.
  *                   This file contains the common defines of the application.
  * @author         : Qilong Huang <jcdiyhelp@qq.com>
  * @date           : 2021-06-08 
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2021 Joy create tech(Suzhou, China) Co., Ltd.
  * All rights reserved.
  *
  *
  ******************************************************************************
  */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __I_EEPROM_H
#define __I_EEPROM_H

#ifdef __cplusplus
extern "C"
{
#endif

/* Global include ---------------------------------------------------------*/
#include "stm32l1xx.h"
#include "stm32l1xx_hal.h"
#include "global.h"

/* Public function declaration---------------------------------------------*/
UINT8_t I_EEPROM_ReadByte(UINT32_t Addr);
TYP_funcRetrun_t I_EEPROM_WriteBytes(UINT32_t Addr, UINT8_t Byte);
TYP_funcRetrun_t I_EEPROM_WriteBuff(UINT32_t OffsetAddress, UINT8_t *Buffer, SINT8_t Length);
TYP_funcRetrun_t I_EEPROM_ReadBuffer(UINT32_t OffsetAddress, UINT8_t *Buffer, SINT8_t Length);
void I_EEPROM_ParaInit(void);


/* Global definition ------------------------------------------------------*/
#define X_AREA_EMPTY            0x00     //APP and Backup area empty flag
#define X_AREA_FULL             0xAA     //APP and Backup area full flag
#define MAX_TABLE_ELN           16

/* Global declaration*/
extern TYP_InfoTab_t InfoTable[MAX_TABLE_ELN];
extern UINT8_t BootInitSeed[4];
extern UINT8_t BootLoaderVersion[12];
extern UINT8_t BootSecurityCode[4];
extern UINT32_t BootStatus;
extern UINT32_t AppSWBiasCode;
extern UINT32_t BakupSWBiasCode;
extern UINT8_t  AppEmptyFlag;
extern UINT32_t BackupEmptyFlag;
extern UINT16_t RequireBCFlashFlag;
extern UINT16_t RequireHalfProgram;
extern UINT16_t BCFlashFinishedFlag;

/* Variable table index*/
enum TabIndex
{
    BootInitFlagIndex        = 0,
    BootVersionIndex         = 1,
    BootSecurityIndex        = 2,
    BootStatusIndex          = 3,
    AppSWBiasIndex           = 4,
    BakupSWBiasIndex         = 5,
    AppEmptyFlagIndex        = 6,
    BackupEmptyFlagIndex     = 7,
    RequireBCFlashIndex      = 8,
    RequireHalfProgramIndex  = 9,
    BCFlashFinishedFlagIndex = 10,
    TableEndIndex
};

#ifdef __cplusplus
}
#endif

#endif /* __I_EEPROM_H */